<template>
	<view class="feedback-wrap">
		<view class="feedback-content">
			<textarea v-model="params.content" class="textarea-wrap" placeholder="请输入您的问题/想法" :maxlength="300" />
			<text class="count">{{ params.content.length }}/ {{ maxLength }}</text>
		</view>
		<view class="feedback-btn">
			<button class="submit-btn" :disabled="!params.content.length" size="default" hover-class="is-hover" @tap="handleSubmit">提交</button>
		</view>
	</view>
</template>

<script>
	import { addFeedback } from '@/common/api_user.js'
	export default {
		data() {
			return {
				maxLength: 300,
				params: {
					content: '',
					images: ''
				}
			}
		},
		methods: {
			handleSubmit() {
				if (!this.hasLogin) {
					this.toLogin()
					return
				}
				addFeedback(this.params).then(res => {
					if (res.code === 200) {
						uni.showToast({
							title: '提交成功',
							icon: 'none'
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 300)
					}
				})
			} 
		}
	}
</script>

<style lang="scss">
	.feedback-wrap {
		position: relative;
		width: 100%;
		height: 100%;
		padding: 40rpx 32rpx;
		box-sizing: border-box;
		.feedback-content {
			position: relative;
			.textarea-wrap {
				width: 100%;
				height: 300px;
				padding: 24rpx 32rpx 50rpx 32rpx;
				box-sizing: border-box;
				background-color: #f7f7f7;
				border-radius: 16px;
			}
			.count {
				position: absolute;
				bottom: 16rpx;
				right: 20rpx;
				font-size: 24rpx;
				color: rgba(52, 49, 79, 0.4);
			}
		}
		.feedback-btn {
			position: absolute;
			bottom: 32rpx;
			left: 32rpx;
			.submit-btn {
				width: 358px;
				height: 48px;
				background-color: #FFDE6D;
				border-radius: 20px;
				backdrop-filter: blur(25px);
				&::after {
					border: none;
				}
			}
		}
	}
</style>